package com.kikyou.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kikyou.pojo.Position;
import com.kikyou.pojo.PositionLevel;
import com.kikyou.pojo.RespBean;
import com.kikyou.service.IOplogService;
import com.kikyou.service.IPositionLevelService;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: kikyouback
 * @author: 李玉龙
 * @create: 2022-03-07 19:28
 **/
@RestController
@RequestMapping("/organization/level")
public class PositionLevelController {
    @Autowired
    IPositionLevelService iPositionLevelService;
    @Autowired
    IOplogService oplogService;
    @ApiOperation(value = "获取所有职位级别创建职位级别")
    @GetMapping("/{currentPage}/{pageSize}")
    public RespBean getAllOrgaLevels(@PathVariable("currentPage") int currentPage, @PathVariable("pageSize") int pageSize){
     return  iPositionLevelService.getAllOrgaLevels(currentPage,pageSize);
    }
    @ApiOperation(value = "创建职位级别")
    @PostMapping("/")
    public RespBean PostOrgaLevels(@RequestBody PositionLevel positionLevel){
       return iPositionLevelService.PostOrgaLevels(positionLevel);
    }
    @ApiOperation(value = "编辑职位级别")
    @PutMapping("/")
    public RespBean PutOrgaLevels(@RequestBody PositionLevel positionLevel){
       return iPositionLevelService.PutOrgaLevels(positionLevel);
    }
    @ApiOperation(value = "删除职位级别")
    @DeleteMapping("/{id}")
    public RespBean DelOrgaLevels(@PathVariable("id") int id){
        boolean b = iPositionLevelService.removeById(id);
        if (b) {
            oplogService.insertMessage("删除职位级别成功");
            return RespBean.success("删除职位级别成功");
        }
        return RespBean.error("删除职位级别失败");
    }
}
